<?php
class validate
{

  function validateRequiredFields($fields)
  {
   $error = 0;
   foreach($fields as $field)
   {
    if($field=='' || $field=null)
    $error++;
   }
   if($error==0)
   return true;
   else
   return false;
  }

	function validateRequired($field_value, $error_msg)
	{
		if($field_value==null || $field_value=='')
		{
			return $error_msg;
		}
		else
		return '';
	}

  function trim($msg)
  {
    $length = strlen($msg);
    $length-=2;
    $error_message = substr($msg, 0, $length);
    return $error_message;
  }

  function addRequiredMessage($msg)
  {
    $default = 'The following field/s should not be left blank: ';
    $error_message = $default.$msg;
    $error_message = $this->trim($error_message);
    return $error_message;
  }
}
?>